using System;
using System.Diagnostics;

namespace Seagull.Model.Stat
{
    [DebuggerDisplay("{ToString()}")]
    public struct Statistic : IEquatable<Statistic>
    {
        public byte Max { get; set; }

        public byte Avg { get; set; }

        public Statistic(byte max, byte avg)
            : this()
        {
            Max = max;
            Avg = avg;
        }

        #region Equality Members

        public bool Equals(Statistic other)
        {
            return other.Max == Max && other.Avg == Avg;
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (obj.GetType() != typeof (Statistic)) return false;
            return Equals((Statistic) obj);
        }

        public override int GetHashCode()
        {
            unchecked
            {
                return (Max.GetHashCode()*397) ^ Avg.GetHashCode();
            }
        }

        public static bool operator ==(Statistic left, Statistic right)
        {
            return left.Equals(right);
        }

        public static bool operator !=(Statistic left, Statistic right)
        {
            return !left.Equals(right);
        }

        #endregion

        public override string ToString()
        {
            return string.Format("Max: {0}, Avg: {1}", Max, Avg);
        }
    }
}